package com.zjm.behavioral.memento.game;

/**
 * 备忘录模式2 游戏角色
 */
public class Client {
    public static void main(String[] args) {
        GameRole gameRole = new GameRole();
        gameRole.setVit(100);
        gameRole.setDef(100);
        System.out.println("大战前的状态");
        gameRole.display();

        // 保存状态
        CareTaker careTaker = new CareTaker();
        careTaker.setMemento(gameRole.createMemento());

        System.out.println("大战中");
        gameRole.setVit(30);
        gameRole.setDef(40);
        gameRole.display();

        System.out.println("大站之后恢复");
        gameRole.recoverGameRoleFromMemento(careTaker.getMemento());

        System.out.println("状态恢复之后");
        gameRole.display();

    }
}
